package gob.pgr.jaxb;

import java.io.StringReader;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;

public class JaxbParser {
	
	public static Object parse(String xml, Class<?> clazz) throws Exception {
		Object object = clazz.newInstance();
		JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
		Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
		object = clazz.cast(unmarshaller.unmarshal(new StringReader(xml)));
		return object;
	}
	
}
